CONTENTS | INDEX | PREV | NEXT
stpchr
FUNCTION
Search for a character in a string (UNIX)
SYNTAX
#include <string.h>
char *ptr = stpchr(s, c)
const char *s;
int c;
DESCRIPTION
This searches for the character c within the string pointed to by s.
The terminating NULL at the end of s is NOT included in the search.
A pointer to the first occurrence of c in s is returned or NULL if c
could not be found. c is converted to a char by stpchr before
beginning the search.
|| NOTE: It is better to use the ANSI standard strchr and strrchr
|| functions.
INPUTS
char *s; pointer to string to search
int c; character to search for
RESULTS
char *ptr; pointer to the first occurrence of the character
c in s, or NULL if c could not be found in s.
SEE ALSO
strchr, strrchr
EXAMPLE
#include <stdio.h>
#include <string.h>
#include <assert.h>
main()
{
char *s = "this is a test";
char *ptr;
ptr = stpchr(s, 'i');
assert(ptr == s + 2);
puts(ptr); /* "is is a test" */
return(0);
}